﻿@model Xms.Web.Customize.Models.EditRelationShipModel

<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            <a data-toggle="collapse"
               href="#collapseTwo">
                <strong>@app.PrivilegeTree?.LastOrDefault().DisplayName</strong>
            </a>
        </h3>
    </div>
    <div id="collapseTwo" class="panel-collapse collapse in">
        <div class="panel-body">
            <form action="/@app.OrganizationUniqueName/customize/@app.ControllerName/@app.ActionName" method="post" id="editform" class="form-horizontal" role="form">
                @Html.AntiForgeryToken()
                @Html.ValidationSummary()
                @Html.HiddenFor(x => x.SolutionId)
                @Html.HiddenFor(x => x.RelationShipId)
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.RelationShipMeta.ReferencedEntityLocalizedName, app.T["relationship_referencedentitylocalizedname"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        @Html.TextBoxFor(x => x.RelationShipMeta.ReferencedEntityLocalizedName, new { @class = "form-control required", @disabled = true })
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.RelationShipMeta.ReferencingEntityLocalizedName, app.T["relationship_referencingentitylocalizedname"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        @Html.TextBoxFor(x => x.RelationShipMeta.ReferencingEntityLocalizedName, new { @class = "form-control required", @disabled = true })
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.RelationShipMeta.Name, app.T["relationship_name"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        @Html.TextBoxFor(x => x.RelationShipMeta.Name, new { @class = "form-control required", @disabled = true })
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.CascadeLinkMask, app.T["relationship_cascadelinkmask"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        <select id="CascadeLinkMask" name="CascadeLinkMask" class="form-control" data-value="@(Model.CascadeLinkMask==0?2:Model.CascadeLinkMask)" @(!Model.IsCustomizable ? "disabled" : "")>
                            <option value="1">@app.T["relationship_cascadelinkmask_parental"]</option>
                            <option value="2">@app.T["relationship_cascadelinkmask_referential"]</option>
                            <option value="3">@app.T["relationship_cascadelinkmask_referentialrestrictdelete"]</option>
                            <option value="4">@app.T["relationship_cascadelinkmask_configurablecascading"]</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.CascadeAssign, app.T["relationship_cascadeassign"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        <select id="CascadeAssign" name="CascadeAssign" class="form-control" data-value="@(Model.CascadeAssign==0?4:Model.CascadeAssign)" @(!Model.IsCustomizable ? "disabled" : "")>
                            <option value="1">@app.T["relationship_cascade"]</option>
                            <option value="2">@app.T["relationship_cascade_activeonly"]</option>
                            <option value="3">@app.T["relationship_cascade_userowned"]</option>
                            <option value="4">@app.T["relationship_nocascade"]</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.CascadeShare, app.T["relationship_cascadeshare"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        <select id="CascadeShare" name="CascadeShare" class="form-control" data-value="@(Model.CascadeShare==0?4:Model.CascadeShare)" @(!Model.IsCustomizable ? "disabled" : "")>
                            <option value="1">@app.T["relationship_cascade"]</option>
                            <option value="2">@app.T["relationship_cascade_activeonly"]</option>
                            <option value="3">@app.T["relationship_cascade_userowned"]</option>
                            <option value="4">@app.T["relationship_nocascade"]</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.CascadeUnShare, app.T["relationship_cascadeunshare"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        <select id="CascadeUnShare" name="CascadeUnShare" class="form-control" data-value="@(Model.CascadeUnShare==0?4:Model.CascadeUnShare)" @(!Model.IsCustomizable ? "disabled" : "")>
                            <option value="1">@app.T["relationship_cascade"]</option>
                            <option value="2">@app.T["relationship_cascade_activeonly"]</option>
                            <option value="3">@app.T["relationship_cascade_userowned"]</option>
                            <option value="4">@app.T["relationship_nocascade"]</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    @Html.LabelFor(x => x.CascadeDelete, app.T["relationship_cascadedelete"], new { @class = "col-sm-2 control-label" })
                    <div class="col-sm-10">
                        <select id="CascadeDelete" name="CascadeDelete" class="form-control" data-value="@(Model.CascadeDelete==0?4:Model.CascadeDelete)" @(!Model.IsCustomizable ? "disabled" : "")>
                            <option value="1">@app.T["relationship_cascade"]</option>
                            <option value="2">@app.T["relationship_cascadedelete_removelink"]</option>
                            <option value="3">@app.T["relationship_cascadedelete_restrict"]</option>
                            <option value="4">@app.T["relationship_nocascade"]</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-12 text-center" id="form-buttons">
                    <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-saved"></span> @app.T["save"]</button>
                    <button type="reset" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> @app.T["reset"]</button>
                </div>
            </form>
        </div>
    </div>
</div>
@section Scripts {
    <script src="/content/js/jquery.form.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script src="/content/js/jquery-validate/jquery.validate.min.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script src="/content/js/jquery-validate/localization/messages_zh.min.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script>
        $(function () {
            //表单验证
            Xms.Web.Form($("#editform"));

            Xms.Web.SelectedValue($('#CascadeLinkMask'), $('#CascadeLinkMask').attr('data-value'));
            Xms.Web.SelectedValue($('#CascadeAssign'), $('#CascadeAssign').attr('data-value'));
            Xms.Web.SelectedValue($('#CascadeShare'), $('#CascadeShare').attr('data-value'));
            Xms.Web.SelectedValue($('#CascadeUnShare'), $('#CascadeUnShare').attr('data-value'));
            Xms.Web.SelectedValue($('#CascadeDelete'), $('#CascadeDelete').attr('data-value'));
        });
    </script>
}